﻿package src.components 
{
	/**
	* 
	* Reliability project
	* -----------------------
	* @author  Dmitrij Boycov
	* @mail    dmitry.boycov@gmail.com
	* @date    April 27, 2010
	* @version 1
	* 
	*/
	
	import fl.controls.Button;
	import fl.controls.TextInput;	
	import fl.controls.TextArea;
	//	astra
	import com.yahoo.astra.fl.containers.Form;
	import com.yahoo.astra.containers.formClasses.FormItem;
	import com.yahoo.astra.containers.formClasses.FormLayoutStyle;
	import com.yahoo.astra.events.FormDataManagerEvent;		
	import com.yahoo.astra.fl.utils.FlValueParser;
	import com.yahoo.astra.layout.LayoutContainer;
	import com.yahoo.astra.layout.modes.BoxLayout;
	import com.yahoo.astra.managers.FormDataManager;	
	//
	import flash.utils.Dictionary;
	//
	import src.components.BForm;	
	
	public class ResForm extends BForm{
		
		protected var resArea:TextArea;
		protected var resAreaFormItem:FormItem; 
		private var itemContainer: LayoutContainer;
		
		public function ResForm() {
			super("Результат вычислений.");
		}
		
		protected override function initUI() {			
			resArea = new TextArea();			
			resArea.width = 250;
			resArea.height = 150;
			resArea.editable = false;
			this.createOkAndCancel();
		}
		
		protected override function initData() {			
			resAreaFormItem = new FormItem("", resArea);
			resAreaFormItem.labelAlign = FormLayoutStyle.LEFT;
			resAreaFormItem.labelWidth = 0;			
			resAreaFormItem.x = 0;
			
			var buttons = new FormItem("",this.okButton);
			buttons.labelWidth = 100;	
			
			var box : BoxLayout = new BoxLayout();
			box.direction = "vertical";
			box.verticalGap = 10;			
			this.itemContainer = new LayoutContainer(box);	
			this.itemContainer.autoMask = false;
			this.itemContainer.x = itemContainer.y = 30;			
			
			this.itemContainer.addChild(resAreaFormItem);			
			this.itemContainer.addChild(buttons);
			this.form.addChild(itemContainer);
		}
		
		public override function setData(dict: Dictionary) {
			if(dict["result"] && dict["result"]!=null){
				resArea.text = dict["result"];			
			}else {
				resArea.text ="Вычислениния не выполнены. Ошибка при сокращение схемы";
			}	
		}
		
		public function add(layoutContainer) {
			if(layoutContainer!=null){
				this.itemContainer.addChildAt(layoutContainer, 0);
				//this.form.addChild(layoutContainer);
			}
		}
		
	}
	
}